<template>
  <div class="risk">
    <!-- <div class="add" @click="add">新增</div> -->
    <eagle-tab-page-list
      url="/DangerCheckTask/GetPageData"
      :params="params"
      @initActive="_initActive"
      @initList="_initList"
    >
      <eagle-cell class="card" v-for="(item, index) in list" :key="index">
        <template v-if="active==0">
          <div class="warn_item">
              <div @click="goDetail(item)">
                <eagle-row>
                  <eagle-col span="24">
                    {{ index + 1 }}、{{ item.CheckTaskName }}</eagle-col
                  >
                </eagle-row>
                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="12">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_type.png"
                      alt=""
                    />{{ item.CheckTypeName }}</eagle-col
                  >
                  <eagle-col span="12">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_danger.png"
                      alt=""
                    />隐患/检查：{{ item.HiddenDangerCnt }}/{{
                      item.CheckCnt
                    }}</eagle-col
                  >
                </eagle-row>

                <eagle-row gutter="20" class="dep_sort">
                  <van-col span="12">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_user.png"
                      alt=""
                    />{{ item.CreateChnName }}</van-col
                  >
                </eagle-row>

                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="24">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />{{ item.StartDate | formatDate }}至{{ item.EndDate | formatDate }}</eagle-col
                  >
                </eagle-row>
              </div>
            </div>
        </template>
        <template v-else>
          <div class="warn_item">
              <div @click="goDetail(item)">
                <eagle-row>
                  <eagle-col span="24">
                    {{ index + 1 }}、{{ item.CheckTaskName }}</eagle-col
                  >
                </eagle-row>
                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="12">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_type.png"
                      alt=""
                    />{{ item.CheckTypeName }}</eagle-col
                  >
                  <eagle-col span="12">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_danger.png"
                      alt=""
                    />隐患/检查：{{ item.HiddenDangerCnt }}/{{
                      item.CheckCnt
                    }}</eagle-col
                  >
                </eagle-row>

                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="12">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_user.png"
                      alt=""
                    />{{ item.CreateChnName }}</eagle-col
                  >
                </eagle-row>

                <eagle-row gutter="20" class="dep_sort">
                  <eagle-col span="24">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />{{ item.StartDate | formatDate }}至{{ item.EndDate | formatDate }}</eagle-col
                  >
                </eagle-row>
              </div>
            </div>
        </template>
      </eagle-cell>
    </eagle-tab-page-list>
  </div>
</template>

<script>
import { formatDate, getDate, getTime } from '@/utils/getDate'

export default {
  data() {
    return {
      active: 0,
      list: [],
      params: [
        {
          title: "进行中的任务",
          dataType: "DangerCheckAreaPlanTask",
          statusType:"NotFinish",
          checkAreaCode: "",
          checkAreaType: "",
          badge: false,
        },
        {
          title: "已结束的任务",
          dataType: "DangerCheckAreaPlanTask",
          statusType:"Finished",
          checkAreaCode: "",
          checkAreaType: "",
          badge: false,
        },
      ],
    };
  },
  created() {
    if (this.$route.query.areaType) {
      this.params[0].checkAreaType = this.$route.query.areaType;
      this.params[1].checkAreaType = this.$route.query.areaType;
    }
    if (this.$route.query.areaCode) {
      this.params[0].checkAreaCode = this.$route.query.areaCode;
      this.params[1].checkAreaCode = this.$route.query.areaCode;
    }
  },
  methods: {
    _initActive(active) {
      this.active = active;
    },
    _initList(list) {
      this.list = list;
    },
    goDetail(item) {
      this.$router.push({
        path: "/Danger/DangerCheckTaskEdit",
        query: { id: item.ID },
      });
    },
  },
};
</script>

<style lang="less" scoped>
.risk {
  background-color: #e8f1f8;
  .info_search {
    padding: 10px;
    border-radius: 5px !important;
    .van-field__control {
      background-color: #ffffff !important;
    }
  }
}
.all_dep {
  background-color: #ffffff;
}
.warn_item {
  margin: 10px;
  /*margin-bottom: 10px;*/
  // padding: 10px 0 10px 10px;
  border-radius: 5px;
  position: relative;
}
.warn_header {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 10px;
  .warn_tag {
    position: absolute;
    right: 0;
    top: 0;
    border-radius: 26.64rem 0 0 26.64rem;
  }
}
.dep_sort {
  // display: flex;
  // flex-wrap: wrap;
  // margin-bottom: 5px;
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
  }
}
.dep_btm {
  display: flex;
  justify-content: flex-end;
  .btm_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}

.choose_btm {
  display: flex;
  width: 100%;
  justify-content: space-between;
  position: fixed;
  bottom: 0;
  background-color: #fff;
  .choose_cancel {
    padding: 0 10px;
    display: flex;
    align-items: center;
    float: left;
  }
  .choose_confirm {
    float: right;
    border-radius: 0;
  }
}
</style>
